﻿using AvaloniaMVVM.Services;
using AvaloniaMVVM.ViewModels;
using Microsoft.Extensions.DependencyInjection;
using System;

namespace AvaloniaMVVM
{
    public class ServiceLocator
    {
        private readonly IServiceProvider _serviceProvider;

        public MainWindowViewModel MainWindowViewModel => _serviceProvider.GetRequiredService<MainWindowViewModel>();

        public ServiceLocator()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton<IPoetryStorage, PoetryStorage>();
            serviceCollection.AddSingleton<MainWindowViewModel>();
            _serviceProvider = serviceCollection.BuildServiceProvider();
        }
    }
}
